package arrayExercise.test1;

public class GoodsTest {
    public static void main(String[] args) {
        //1.定义一个数组，长度为3
        Goods[] arr = new Goods[3];

        //2.创建三个商品对象
        Goods g1 = new Goods("001","Iphone13",4000,200);
        Goods g2 = new Goods("002","typeC充电头",200,400);
        Goods g3 = new Goods("003","typeC充电器",74,145);

        //3.把商品添加到数组中
        arr[0] = g1;
        arr[1] = g2;
        arr[2] = g3;

        //遍历打印
        for (int i = 0; i < arr.length; i++) {
            Goods goods = arr[i];
            System.out.println(goods.toString());
        }
    }
}
